import {createPlainModule} from "@peryl/utils/createPlainModule";
import {markRaw, reactive, SimpleFunction} from "@peryl/react-compose";

export function createMicroModule</*@formatter:off*/
  DefaultConfig extends Record<string, any>,
  CustomConfig extends Record<string, any>,
  UseConfig extends CustomConfig & Partial<DefaultConfig>,
  OptionConfig extends CustomConfig & DefaultConfig,
  Option extends { config: OptionConfig, useConfig: UseConfig, defaultConfig: DefaultConfig }
  /*@formatter:on*/>(name: string) {
  return createPlainModule</*@formatter:off*/
    DefaultConfig,
    CustomConfig,
    UseConfig,
    OptionConfig,
    Option
    /*@formatter:on*/>({
    name,
    onBeforeUnmount: (fn: SimpleFunction) => null,
    reactive: reactive as any,
    markRaw
  });
}
